<!--内容开始-->
<section class="content">
    <div class="search">
        <form class="form-inline" action="{:url('index')}">
            <a class="btn btn-flat btn-primary m_10" href="{:url('index')}">显示全部</a>
            <a class="btn btn-flat btn-success m_10 f_r m_t_5" onclick="javascript :history.back(-1)"><i
                    class="fa fa-undo m-r-10"></i>返 回</a>
        </form>
    </div>
    <!--数据表开始-->
    <div class="row">
        <div class="col-xs-12">
            <div class="box box-body">
                {if $info}
                <form method="post" action="{:url('fieldEditPost')}">
                    <input type="hidden" name="id" value="{$info.id}"/>
                    <input type="hidden" name="oldfield" value="{$info.field}"/>
                    <input type="hidden" name="type" value="{$info.type}"/>
                    {else /}
                    <form method="post" action="{:url('fieldAddPost')}">
                        {/if}
                        <input type="hidden" name="moduleid" value="{$moduleid}"/>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">字段类型</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <select id="type" name="type" class="form-control" {$info ? 'disabled' : ''}>
                                    <option value=''>请选择字段类型</option>
                                    <option value="cate" {$info.type == 'cate' ? 'selected="selected"' : ''}>栏目</option>
                                    <option value="title" {$info.type == 'title' ? 'selected="selected"' : ''}>标题</option>
                                    <option value="text" {$info.type == 'text' ? 'selected="selected"' : ''} >单行文本</option>
                                    <option value="textarea" {$info.type == 'textarea' ? 'selected="selected"' : ''}>多行文本</option>
                                    <option value="editor" {$info.type == 'editor' ? 'selected="selected"' : ''}>编辑器</option>
                                    <option value="select" {$info.type == 'select' ? 'selected="selected"' : ''}>下拉列表</option>
                                    <option value="radio" {$info.type == 'radio' ? 'selected="selected"' : ''}>单选按钮</option>
                                    <option value="checkbox" {$info.type == 'checkbox' ? 'selected="selected"' : ''}>复选框</option>
                                    <option value="image" {$info.type == 'image' ? 'selected="selected"' : ''}>单张图片</option>
                                    <option value="images" {$info.type == 'images' ? 'selected="selected"' : ''}>多张图片</option>
                                    <option value="file" {$info.type == 'file' ? 'selected="selected"' : ''}>文件上传</option>
                                    <option value="number" {$info.type == 'number' ? 'selected="selected"' : ''}>数字</option>
                                    <option value="datetime" {$info.type == 'datetime' ? 'selected="selected"' : ''}>日期和时间</option>
                                    <option value="template" {$info.type == 'template' ? 'selected="selected"' : ''}>模版</option>
                                    <option value="tag" {$info.type == 'tag' ? 'selected="selected"' : ''}>标签</option>
                                    <!--<option value="posid" >推荐位</option>-->
                                    <!--<option value="template">模板选择</option>-->
                                    </select>

                                </div>
                                <div class="col-xs-1 col-sm-4 col-md-6 col-lg-6 dd_ts">*</div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">字段名</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <input type="text" name="field" class="form-control" placeholder="必填：字段名"
                                           value="{$info.field?$info.field:''}">
                                </div>
                                <div class="col-xs-12 col-sm-4 col-md-6 col-lg-6 dd_ts">* 字段英文名称，如 title</div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">别名</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <input type="text" name="name" class="form-control" placeholder="必填：别名"
                                           value="{$info.name?$info.name:''}">
                                </div>
                                <div class="col-xs-12 col-sm-4 col-md-6 col-lg-6 dd_ts">* 字段中文名称，如 标题</div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">必填</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <div class="dd_radio_lable_left">
                                        <label class="dd_radio_lable">
                                            <input type="radio" name="required" value="1" class="dd_radio"
                                                   {$info.required==1?'checked':''}><span>是</span>
                                        </label>
                                        <label class="dd_radio_lable">
                                            <input type="radio" name="required" value="0" class="dd_radio"
                                                   {$info.required==0?'checked':''}><span>否</span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">字符长度</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <div class="col-sm-4 col-xs-4 p_r_0">
                                        <input type="text" name="minlength" class="form-control"
                                               value="{$info.minlength?$info.minlength:'0'}">
                                    </div>
                                    <div class="col-sm-1 col-xs-1 line_height_38">-</div>
                                    <div class="col-sm-4 col-xs-4 p_r_0">
                                        <input type="text" name="maxlength" class="form-control"
                                               value="{$info.maxlength?$info.maxlength:'0'}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">字段设置</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <div class="dd_radio_lable_left" id="field_setup">
                                        <!--ajax调用文件-->
                                        <!--ajax调用结束-->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">状态</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <div class="dd_radio_lable_left">
                                        {if $info}
                                        <label class="dd_radio_lable">
                                            <input type="radio" name="status" value="1" class="dd_radio" {$info.status ?
                                            'checked' : ''}><span>显示</span>
                                        </label>
                                        <label class="dd_radio_lable">
                                            <input type="radio" name="status" value="0" class="dd_radio" {$info.status ?
                                            '' : 'checked'}><span>隐藏</span>
                                        </label>
                                        {else /}
                                        <label class="dd_radio_lable">
                                            <input type="radio" name="status" value="1" class="dd_radio" checked><span>显示</span>
                                        </label>
                                        <label class="dd_radio_lable">
                                            <input type="radio" name="status" value="0" class="dd_radio"><span>隐藏</span>
                                        </label>
                                        {/if}
                                    </div>
                                </div>
                                <div class="col-xs-1 col-sm-4 col-md-6 col-lg-6 dd_ts">*</div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <label class="col-xs-4 col-sm-2 col-md-2 col-lg-1 control-label dd_input_l">排序</label>
                                <div class="col-xs-7 col-sm-6 col-md-4 col-lg-4">
                                    <input type="text" name="sort" class="form-control" placeholder="请输入排序"
                                           value="{$info.sort ? $info.sort : '50'}">
                                </div>
                                <div class="col-xs-12 col-sm-4 col-md-6 col-lg-6 dd_ts"> * 排序为从小到大排序，默认为50</div>
                            </div>
                        </div>
                        <!---->
                        <div class="row dd_input_group">
                            <div class="form-group">
                                <div class="col-xs-12 col-sm-8 col-md-6 col-lg-5 text-center">
                                    <button type="submit" class="btn btn-flat btn-primary ">提 交</button>
                                    <button type="button" class="btn btn-flat btn-default"
                                            onclick="javascript :history.back(-1)">返 回
                                    </button>
                                </div>

                            </div>
                        </div>
                    </form>
            </div>
            <!-- /.box -->
        </div>
    </div>
    <!--数据表结束-->
</section>
<!--内容结束-->

<script>
    $(function(){
        $("#type").change(function(){
            var type = $(this).val();
            var url =  "{:url('fieldAddPost')}?isajax=1&moduleid={$moduleid}&type="+type;
            field_setting(type,url);
        });

        {if $info}
        var type = '{$info.type}';
        var name = '{$info.field}'
        var url =  "{:url('fieldAddPost')}?isajax=1&moduleid={$moduleid}&type="+type+"&name="+name;
        field_setting(type,url);
        {/if}

    })
    //选择后变更
    function field_setting(type,url,data){
        $.ajax({
            type: "POST",
            url: url,
            data: '',
            beforeSend:function(){
                $('#field_setup').html('<i class="fa fa-spinner fa-spin fa-fw"></i>');
            },
            success: function(msg){
                $('#field_setup').html(msg);
            }
        });
    }
</script>
